/**
 * 按钮
 * 扩展显示隐藏能力
 */

import * as React from 'react'
import { Button, Popconfirm, PopconfirmProps } from 'antd';
import { useTranslation } from 'react-i18next';

interface ConfirmButtonProps extends PopconfirmProps {

}

export default function ConfirmButton(props: ConfirmButtonProps) {
  const { t } = useTranslation();
  let { style, title, description, children, onConfirm, ...rest } = props;
  if (!title) {
    title = t("delete")
  }
  if (!description) {
    description = t("deleteConfirm")
  }
  if (!children) {
    children = t("delete")
  }
  return <Popconfirm
    placement="topRight"
    okButtonProps={{ color: "danger", variant: "solid" }}
    onConfirm={onConfirm}
    title={title}
    description={description}
    {...rest}
    style={style}
  >
    <Button danger type="link" >{children}</Button>
  </Popconfirm>
}